
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>7个有用的Vue开发技巧 · 记录技术文档内容</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="zhengyuliang">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-sectionx/sectionx.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-toggle-chapters/toggle.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search-plus/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-donate/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="Vue this.$router.push、replace、go的区别.html" />
    
    
    <link rel="prev" href="../HTML/浏览器里的本地数据库：IndexedDB.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        <li class="header">CSS</li>
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../CSS/18种CSS命名和书写规范.html">
            
                <a href="../CSS/18种CSS命名和书写规范.html">
            
                    
                    18种CSS命名和书写规范
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../CSS/灵活运用CSS开发技巧.html">
            
                <a href="../CSS/灵活运用CSS开发技巧.html">
            
                    
                    灵活运用CSS开发技巧
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../CSS/自适应 flex grid.html">
            
                <a href="../CSS/自适应 flex grid.html">
            
                    
                    自适应 Flex Grid
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">HTML</li>
        
        
    
        <li class="chapter " data-level="2.1" data-path="../HTML/浏览器里的本地数据库：IndexedDB.html">
            
                <a href="../HTML/浏览器里的本地数据库：IndexedDB.html">
            
                    
                    浏览器里的本地数据库：IndexedDB
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">Vue</li>
        
        
    
        <li class="chapter active" data-level="3.1" data-path="7个有用的Vue开发技巧.html">
            
                <a href="7个有用的Vue开发技巧.html">
            
                    
                    7个有用的Vue开发技巧
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="Vue this.$router.push、replace、go的区别.html">
            
                <a href="Vue this.$router.push、replace、go的区别.html">
            
                    
                    Vue This.$Router.Push、Replace、Go的区别
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="Vue 的父组件和子组件生命周期钩子函数执行顺序？.html">
            
                <a href="Vue 的父组件和子组件生命周期钩子函数执行顺序？.html">
            
                    
                    Vue 的父组件和子组件生命周期钩子函数执行顺序？
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4" data-path="Vue.set和this.$set应用的场景.html">
            
                <a href="Vue.set和this.$set应用的场景.html">
            
                    
                    Vue.Set和This.$Set应用的场景
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5" data-path="vue高级技巧.html">
            
                <a href="vue高级技巧.html">
            
                    
                    Vue高级技巧
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.6" data-path="从 0 开始手把手带你搭建一套规范的 Vue3.x 项目工程环境.html">
            
                <a href="从 0 开始手把手带你搭建一套规范的 Vue3.x 项目工程环境.html">
            
                    
                    从 0 开始手把手带你搭建一套规范的 Vue3.X 项目工程环境
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.7" data-path="浅析 vue-router 源码和动态路由权限分配.html">
            
                <a href="浅析 vue-router 源码和动态路由权限分配.html">
            
                    
                    浅析 Vue Router 源码和动态路由权限分配
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.8" data-path="父组件监听到子组件的生命周期.html">
            
                <a href="父组件监听到子组件的生命周期.html">
            
                    
                    父组件监听到子组件的生命周期
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.9" data-path="理解Vue.mixin，利用Vue.mixin正确的偷懒.html">
            
                <a href="理解Vue.mixin，利用Vue.mixin正确的偷懒.html">
            
                    
                    理解Vue.Mixin，利用Vue.Mixin正确的偷懒
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">JavaScript</li>
        
        
    
        <li class="chapter " data-level="4.1" data-path="../javaScript/5个技巧让你更好的编写 JavaScript(ES6">
            
                <span>
            
                    
                    5个技巧让你更好的编写 JavaScript(ES6) 中条件语句
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.2" data-path="../javaScript/5种常见函数的写法和调用方式.html">
            
                <a href="../javaScript/5种常见函数的写法和调用方式.html">
            
                    
                    5种常见函数的写法和调用方式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3" data-path="../javaScript/7道javascript题，让你理解基本的javascript.html">
            
                <a href="../javaScript/7道javascript题，让你理解基本的javascript.html">
            
                    
                    7道Javascript题，让你理解基本的Javascript
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.4" data-path="../javaScript/Array.from(">
            
                <span>
            
                    
                    Array.From() 五个超好用的用途
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.5" data-path="../javaScript/ES6汇总资料.html">
            
                <a href="../javaScript/ES6汇总资料.html">
            
                    
                    ES6汇总资料
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.6" data-path="../javaScript/JS开发必须知道的41个技巧.html">
            
                <a href="../javaScript/JS开发必须知道的41个技巧.html">
            
                    
                    JS开发必须知道的41个技巧
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.7" data-path="../javaScript/JavaScript之防抖Debounce和节流Throttle.html">
            
                <a href="../javaScript/JavaScript之防抖Debounce和节流Throttle.html">
            
                    
                    JavaScript之防抖Debounce和节流Throttle
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.8" data-path="../javaScript/JavaScript数组求并集，交集和差集.html">
            
                <a href="../javaScript/JavaScript数组求并集，交集和差集.html">
            
                    
                    JavaScript数组求并集，交集和差集
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.9" data-path="../javaScript/JavaScript的优雅写法.html">
            
                <a href="../javaScript/JavaScript的优雅写法.html">
            
                    
                    JavaScript的优雅写法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.10" data-path="../javaScript/axios知识点.html">
            
                <a href="../javaScript/axios知识点.html">
            
                    
                    Axios知识点
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.11" data-path="../javaScript/javascript核心知识.html">
            
                <a href="../javaScript/javascript核心知识.html">
            
                    
                    Javascript核心知识
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.12" data-path="../javaScript/this、apply、call、bind.html">
            
                <a href="../javaScript/this、apply、call、bind.html">
            
                    
                    This、Apply、Call、Bind
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.13" data-path="../javaScript/前端js常用的60余种工具方法.html">
            
                <a href="../javaScript/前端js常用的60余种工具方法.html">
            
                    
                    前端Js常用的60余种工具方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.14" data-path="../javaScript/前端异常的捕获与处理.html">
            
                <a href="../javaScript/前端异常的捕获与处理.html">
            
                    
                    前端异常的捕获与处理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.15" data-path="../javaScript/在 JavaScript 中交换值的 10 种方法.html">
            
                <a href="../javaScript/在 JavaScript 中交换值的 10 种方法.html">
            
                    
                    在 JavaScript 中交换值的 10 种方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.16" data-path="../javaScript/常用的前端JavaScript方法封装.html">
            
                <a href="../javaScript/常用的前端JavaScript方法封装.html">
            
                    
                    常用的前端JavaScript方法封装
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.17" data-path="../javaScript/异步神器Async-await介绍与填坑.html">
            
                <a href="../javaScript/异步神器Async-await介绍与填坑.html">
            
                    
                    异步神器Async Await介绍与填坑
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.18" data-path="../javaScript/灵活运用JS开发技巧.html">
            
                <a href="../javaScript/灵活运用JS开发技巧.html">
            
                    
                    灵活运用JS开发技巧
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.19" data-path="../javaScript/编写高质量可维护的代码：一目了然的注释.html">
            
                <a href="../javaScript/编写高质量可维护的代码：一目了然的注释.html">
            
                    
                    编写高质量可维护的代码：一目了然的注释
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.20" data-path="../javaScript/编写高质量可维护的代码：优化逻辑判断.html">
            
                <a href="../javaScript/编写高质量可维护的代码：优化逻辑判断.html">
            
                    
                    编写高质量可维护的代码：优化逻辑判断
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.21" data-path="../javaScript/编写高质量可维护的代码：优雅命名.html">
            
                <a href="../javaScript/编写高质量可维护的代码：优雅命名.html">
            
                    
                    编写高质量可维护的代码：优雅命名
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.22" data-path="../javaScript/编写高质量可维护的代码：数据建模.html">
            
                <a href="../javaScript/编写高质量可维护的代码：数据建模.html">
            
                    
                    编写高质量可维护的代码：数据建模
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">Life Exp</li>
        
        
    
        <li class="chapter " data-level="5.1" data-path="../life_exp/告别平庸的15个小方法.html">
            
                <a href="../life_exp/告别平庸的15个小方法.html">
            
                    
                    告别平庸的15个小方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.2" data-path="../life_exp/日志记录.html">
            
                <a href="../life_exp/日志记录.html">
            
                    
                    日志记录
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.3" data-path="../life_exp/程序员的发展方向.html">
            
                <a href="../life_exp/程序员的发展方向.html">
            
                    
                    程序员的发展方向
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.4" data-path="../message/">
            
                <a href="../message/">
            
                    
                    Message
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">Technology</li>
        
        
    
        <li class="chapter " data-level="6.1" data-path="../technology/WebSocket.html">
            
                <a href="../technology/WebSocket.html">
            
                    
                    WebSocket
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.2" data-path="../technology/npm常用命令大全.html">
            
                <a href="../technology/npm常用命令大全.html">
            
                    
                    Npm常用命令大全
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.3" data-path="../technology/智能照明项目说明.html">
            
                <a href="../technology/智能照明项目说明.html">
            
                    
                    智能照明项目说明
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.4" data-path="../technology/规范化git的提交信息.html">
            
                <a href="../technology/规范化git的提交信息.html">
            
                    
                    规范化Git的提交信息
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">Tutorial</li>
        
        
    
        <li class="chapter " data-level="7.1" data-path="../tutorial/Esmap地图详解.html">
            
                <a href="../tutorial/Esmap地图详解.html">
            
                    
                    Esmap地图详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.2" data-path="../tutorial/npm镜像切换.html">
            
                <a href="../tutorial/npm镜像切换.html">
            
                    
                    Npm镜像切换
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.3" data-path="../tutorial/发布npm的教程.html">
            
                <a href="../tutorial/发布npm的教程.html">
            
                    
                    发布Npm的教程
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >7个有用的Vue开发技巧</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div class="search-plus" id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <html><head></head><body><div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><ul><ul><li><span class="title-icon "></span><a href="#7&#x4E2A;&#x6709;&#x7528;&#x7684;vue&#x5F00;&#x53D1;&#x6280;&#x5DE7;"><b>1.1.1. </b>7&#x4E2A;&#x6709;&#x7528;&#x7684;Vue&#x5F00;&#x53D1;&#x6280;&#x5DE7;</a></li></ul></ul></ul></div><a href="#" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><h3 id="7&#x4E2A;&#x6709;&#x7528;&#x7684;vue&#x5F00;&#x53D1;&#x6280;&#x5DE7;"><a name="7&#x4E2A;&#x6709;&#x7528;&#x7684;vue&#x5F00;&#x53D1;&#x6280;&#x5DE7;" class="anchor-navigation-ex-anchor" href="#7&#x4E2A;&#x6709;&#x7528;&#x7684;vue&#x5F00;&#x53D1;&#x6280;&#x5DE7;"><i class="fa fa-link" aria-hidden="true"></i></a>1.1.1. 7&#x4E2A;&#x6709;&#x7528;&#x7684;Vue&#x5F00;&#x53D1;&#x6280;&#x5DE7;</h3>
<blockquote>
<p>7&#x4E2A;&#x6709;&#x7528;&#x7684;Vue&#x5F00;&#x53D1;&#x6280;&#x5DE7;&#xFF0C;&#x597D;&#x597D;&#x7406;&#x89E3;&#xFF0C;&#x611F;&#x5230;&#x8FD8;&#x4E0D;&#x9519;&#xFF0C;&#x975E;&#x5E38;&#x597D;</p>
</blockquote>
<h4 id="1-&#x72B6;&#x6001;&#x5171;&#x4EAB;"><a name="1-&#x72B6;&#x6001;&#x5171;&#x4EAB;" class="anchor-navigation-ex-anchor" href="#1-&#x72B6;&#x6001;&#x5171;&#x4EAB;"><i class="fa fa-link" aria-hidden="true"></i></a>1 &#x72B6;&#x6001;&#x5171;&#x4EAB;</h4>
<p>&#x968F;&#x7740;&#x7EC4;&#x4EF6;&#x7684;&#x7EC6;&#x5316;&#xFF0C;&#x5C31;&#x4F1A;&#x9047;&#x5230;&#x591A;&#x7EC4;&#x4EF6;&#x72B6;&#x6001;&#x5171;&#x4EAB;&#x7684;&#x60C5;&#x51B5;&#xFF0C;Vuex&#x5F53;&#x7136;&#x53EF;&#x4EE5;&#x89E3;&#x51B3;&#x8FD9;&#x7C7B;&#x95EE;&#x9898;&#xFF0C;&#x4E0D;&#x8FC7;&#x5C31;&#x50CF;Vuex&#x5B98;&#x65B9;&#x6587;&#x6863;&#x6240;&#x8BF4;&#x7684;&#xFF0C;&#x5982;&#x679C;&#x5E94;&#x7528;&#x4E0D;&#x591F;&#x5927;&#xFF0C;&#x4E3A;&#x907F;&#x514D;&#x4EE3;&#x7801;&#x7E41;&#x7410;&#x5197;&#x4F59;&#xFF0C;&#x6700;&#x597D;&#x4E0D;&#x8981;&#x4F7F;&#x7528;&#x5B83;&#xFF0C;&#x4ECA;&#x5929;&#x6211;&#x4EEC;&#x4ECB;&#x7ECD;&#x7684;&#x662F;vue.js 2.6&#x65B0;&#x589E;&#x52A0;&#x7684;Observable API &#xFF0C;&#x901A;&#x8FC7;&#x4F7F;&#x7528;&#x8FD9;&#x4E2A;Api&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x5E94;&#x5BF9;&#x4E00;&#x4E9B;&#x7B80;&#x5355;&#x7684;&#x8DE8;&#x7EC4;&#x4EF6;&#x6570;&#x636E;&#x72B6;&#x6001;&#x5171;&#x4EAB;&#x7684;&#x60C5;&#x51B5;&#x3002;</p>
<p>&#x5982;&#x4E0B;&#x8FD9;&#x4E2A;&#x4F8B;&#x5B50;&#xFF0C;&#x6211;&#x4EEC;&#x5C06;&#x5728;&#x7EC4;&#x4EF6;&#x5916;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;<code>store</code>&#xFF0C;&#x7136;&#x540E;&#x5728;<code>App.vue</code>&#x7EC4;&#x4EF6;&#x91CC;&#x9762;&#x4F7F;&#x7528;store.js&#x63D0;&#x4F9B;&#x7684;<code>store</code>&#x548C;<code>mutation</code>&#x65B9;&#x6CD5;&#xFF0C;&#x540C;&#x7406;&#x5176;&#x5B83;&#x7EC4;&#x4EF6;&#x4E5F;&#x53EF;&#x4EE5;&#x8FD9;&#x6837;&#x4F7F;&#x7528;&#xFF0C;&#x4ECE;&#x800C;&#x5B9E;&#x73B0;&#x591A;&#x4E2A;&#x7EC4;&#x4EF6;&#x5171;&#x4EAB;&#x6570;&#x636E;&#x72B6;&#x6001;&#x3002;</p>
<p>&#x9996;&#x5148;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;store.js&#xFF0C;&#x5305;&#x542B;&#x4E00;&#x4E2A;<code>store</code>&#x548C;&#x4E00;&#x4E2A;<code>mutations</code>&#xFF0C;&#x5206;&#x522B;&#x7528;&#x6765;&#x6307;&#x5411;&#x6570;&#x636E;&#x548C;&#x5904;&#x7406;&#x65B9;&#x6CD5;&#x3002;</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> Vue <span class="hljs-keyword">from</span> <span class="hljs-string">&quot;vue&quot;</span>;

<span class="hljs-keyword">export</span> <span class="hljs-keyword">const</span> store = Vue.observable({ <span class="hljs-attr">count</span>: <span class="hljs-number">0</span> });

<span class="hljs-keyword">export</span> <span class="hljs-keyword">const</span> mutations = {
  setCount(count) {
    store.count = count;
  }
};
</code></pre>
<p>&#x7136;&#x540E;&#x5728;<code>App.vue</code>&#x91CC;&#x9762;&#x5F15;&#x5165;&#x8FD9;&#x4E2A;store.js&#xFF0C;&#x5728;&#x7EC4;&#x4EF6;&#x91CC;&#x9762;&#x4F7F;&#x7528;&#x5F15;&#x5165;&#x7684;&#x6570;&#x636E;&#x548C;&#x65B9;&#x6CD5;</p>
<pre><code class="lang-javascript">&lt;template&gt;
  <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">id</span>=<span class="hljs-string">&quot;app&quot;</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">img</span> <span class="hljs-attr">width</span>=<span class="hljs-string">&quot;25%&quot;</span> <span class="hljs-attr">src</span>=<span class="hljs-string">&quot;./assets/logo.png&quot;</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>count:<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">button</span> @<span class="hljs-attr">click</span>=<span class="hljs-string">&quot;setCount(count+1)&quot;</span>&gt;</span>+1<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">button</span> @<span class="hljs-attr">click</span>=<span class="hljs-string">&quot;setCount(count-1)&quot;</span>&gt;</span>-1<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">template</span>&gt;</span></span>

&lt;script&gt;
<span class="hljs-keyword">import</span> { store, mutations } <span class="hljs-keyword">from</span> <span class="hljs-string">&quot;./store&quot;</span>;
<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> {
  <span class="hljs-attr">name</span>: <span class="hljs-string">&quot;App&quot;</span>,
  <span class="hljs-attr">computed</span>: {
    count() {
      <span class="hljs-keyword">return</span> store.count;
    }
  },
  <span class="hljs-attr">methods</span>: {
    <span class="hljs-attr">setCount</span>: mutations.setCount
  }
};
<span class="xml"><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span></span>
&lt;style&gt;
</code></pre>
<h4 id="2-&#x957F;&#x5217;&#x8868;&#x6027;&#x80FD;&#x4F18;&#x5316;"><a name="2-&#x957F;&#x5217;&#x8868;&#x6027;&#x80FD;&#x4F18;&#x5316;" class="anchor-navigation-ex-anchor" href="#2-&#x957F;&#x5217;&#x8868;&#x6027;&#x80FD;&#x4F18;&#x5316;"><i class="fa fa-link" aria-hidden="true"></i></a>2 &#x957F;&#x5217;&#x8868;&#x6027;&#x80FD;&#x4F18;&#x5316;</h4>
<p>&#x6211;&#x4EEC;&#x5E94;&#x8BE5;&#x90FD;&#x77E5;&#x9053;<code>vue</code>&#x4F1A;&#x901A;&#x8FC7;<code>object.defineProperty</code>&#x5BF9;&#x6570;&#x636E;&#x8FDB;&#x884C;&#x52AB;&#x6301;&#xFF0C;&#x6765;&#x5B9E;&#x73B0;&#x89C6;&#x56FE;&#x54CD;&#x5E94;&#x6570;&#x636E;&#x7684;&#x53D8;&#x5316;&#xFF0C;&#x7136;&#x800C;&#x6709;&#x4E9B;&#x65F6;&#x5019;&#x6211;&#x4EEC;&#x7684;&#x7EC4;&#x4EF6;&#x5C31;&#x662F;&#x7EAF;&#x7CB9;&#x7684;&#x6570;&#x636E;&#x5C55;&#x793A;&#xFF0C;&#x4E0D;&#x4F1A;&#x6709;&#x4EFB;&#x4F55;&#x6539;&#x53D8;&#xFF0C;&#x6211;&#x4EEC;&#x5C31;&#x4E0D;&#x9700;&#x8981;<code>vue</code>&#x6765;&#x52AB;&#x6301;&#x6211;&#x4EEC;&#x7684;&#x6570;&#x636E;&#xFF0C;&#x5728;&#x5927;&#x91CF;&#x6570;&#x636E;&#x5C55;&#x793A;&#x7684;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x8FD9;&#x80FD;&#x591F;&#x5F88;&#x660E;&#x663E;&#x7684;&#x51CF;&#x5C11;&#x7EC4;&#x4EF6;&#x521D;&#x59CB;&#x5316;&#x7684;&#x65F6;&#x95F4;&#xFF0C;&#x90A3;&#x5982;&#x4F55;&#x7981;&#x6B62;<code>vue</code>&#x52AB;&#x6301;&#x6211;&#x4EEC;&#x7684;&#x6570;&#x636E;&#x5462;&#xFF1F;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;<code>object.freeze</code>&#x65B9;&#x6CD5;&#x6765;&#x51BB;&#x7ED3;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#xFF0C;&#x4E00;&#x65E6;&#x88AB;&#x51BB;&#x7ED3;&#x7684;&#x5BF9;&#x8C61;&#x5C31;&#x518D;&#x4E5F;&#x4E0D;&#x80FD;&#x88AB;&#x4FEE;&#x6539;&#x4E86;&#x3002;</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> {
  <span class="hljs-attr">data</span>: <span class="hljs-function"><span class="hljs-params">()</span> =&gt;</span> ({
    <span class="hljs-attr">users</span>: {}
  }),
  <span class="hljs-keyword">async</span> created() {
    <span class="hljs-keyword">const</span> users = <span class="hljs-keyword">await</span> axios.get(<span class="hljs-string">&quot;/api/users&quot;</span>);
    <span class="hljs-keyword">this</span>.users = <span class="hljs-built_in">Object</span>.freeze(users);
  }
};
</code></pre>
<p>&#x53E6;&#x5916;&#x9700;&#x8981;&#x8BF4;&#x660E;&#x7684;&#x662F;&#xFF0C;&#x8FD9;&#x91CC;&#x53EA;&#x662F;&#x51BB;&#x7ED3;&#x4E86;<code>users</code>&#x7684;&#x503C;&#xFF0C;&#x5F15;&#x7528;&#x4E0D;&#x4F1A;&#x88AB;&#x51BB;&#x7ED3;&#xFF0C;&#x5F53;&#x6211;&#x4EEC;&#x9700;&#x8981;<code>reactive</code>&#x6570;&#x636E;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x91CD;&#x65B0;&#x7ED9;<code>users</code>&#x8D4B;&#x503C;&#x3002;</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> {
  <span class="hljs-attr">data</span>: <span class="hljs-function"><span class="hljs-params">()</span> =&gt;</span> ({
    <span class="hljs-attr">users</span>: []
  }),
  <span class="hljs-keyword">async</span> created() {
    <span class="hljs-keyword">const</span> users = <span class="hljs-keyword">await</span> axios.get(<span class="hljs-string">&quot;/api/users&quot;</span>);
    <span class="hljs-keyword">this</span>.users = <span class="hljs-built_in">Object</span>.freeze(users);
  },
  <span class="hljs-attr">methods</span>:{
    <span class="hljs-comment">// &#x6539;&#x53D8;&#x503C;&#x4E0D;&#x4F1A;&#x89E6;&#x53D1;&#x89C6;&#x56FE;&#x54CD;&#x5E94;</span>
    <span class="hljs-keyword">this</span>.users[<span class="hljs-number">0</span>] = newValue
    <span class="hljs-comment">// &#x6539;&#x53D8;&#x5F15;&#x7528;&#x4F9D;&#x7136;&#x4F1A;&#x89E6;&#x53D1;&#x89C6;&#x56FE;&#x54CD;&#x5E94;</span>
    <span class="hljs-keyword">this</span>.users = newArray
  }
};
</code></pre>
<h4 id="3-&#x53BB;&#x9664;&#x591A;&#x4F59;&#x7684;&#x6837;&#x5F0F;"><a name="3-&#x53BB;&#x9664;&#x591A;&#x4F59;&#x7684;&#x6837;&#x5F0F;" class="anchor-navigation-ex-anchor" href="#3-&#x53BB;&#x9664;&#x591A;&#x4F59;&#x7684;&#x6837;&#x5F0F;"><i class="fa fa-link" aria-hidden="true"></i></a>3 &#x53BB;&#x9664;&#x591A;&#x4F59;&#x7684;&#x6837;&#x5F0F;</h4>
<p>&#x968F;&#x7740;&#x9879;&#x76EE;&#x8D8A;&#x6765;&#x8D8A;&#x5927;&#xFF0C;&#x4E66;&#x5199;&#x7684;&#x4E0D;&#x6CE8;&#x610F;&#xFF0C;&#x4E0D;&#x81EA;&#x7136;&#x7684;&#x5C31;&#x4F1A;&#x4EA7;&#x751F;&#x4E00;&#x4E9B;&#x591A;&#x4F59;&#x7684;css&#xFF0C;&#x5C0F;&#x9879;&#x76EE;&#x8FD8;&#x597D;&#xFF0C;&#x4E00;&#x65E6;&#x9879;&#x76EE;&#x5927;&#x4E86;&#x4EE5;&#x540E;&#xFF0C;&#x591A;&#x4F59;&#x7684;css&#x4F1A;&#x8D8A;&#x6765;&#x8D8A;&#x591A;&#xFF0C;&#x5BFC;&#x81F4;&#x5305;&#x8D8A;&#x6765;&#x8D8A;&#x5927;&#xFF0C;&#x4ECE;&#x800C;&#x5F71;&#x54CD;&#x9879;&#x76EE;&#x8FD0;&#x884C;&#x6027;&#x80FD;&#xFF0C;&#x6240;&#x4EE5;&#x6709;&#x5FC5;&#x8981;&#x5728;&#x6B63;&#x5F0F;&#x73AF;&#x5883;&#x53BB;&#x9664;&#x6389;&#x8FD9;&#x4E9B;&#x591A;&#x4F59;&#x7684;css&#xFF0C;&#x8FD9;&#x91CC;&#x63A8;&#x8350;&#x4E00;&#x4E2A;&#x5E93;<a href="https://links.jianshu.com/go?to=https%3A%2F%2Flink.juejin.im%2F%3Ftarget%3Dhttps%3A%2F%2Fwww.purgecss.com%2F" target="_blank">purgecss</a>&#xFF0C;&#x652F;&#x6301;CLI&#x3001;JavascriptApi&#x3001;Webpack&#x7B49;&#x591A;&#x79CD;&#x65B9;&#x5F0F;&#x4F7F;&#x7528;&#xFF0C;&#x901A;&#x8FC7;&#x8FD9;&#x4E2A;&#x5E93;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x5F88;&#x5BB9;&#x6613;&#x7684;&#x53BB;&#x9664;&#x6389;&#x591A;&#x4F59;&#x7684;css&#x3002;</p>
<pre><code class="lang-javascript">&lt;h1&gt;Hello Vanilla!&lt;/h1&gt;
&lt;div&gt;
  We use Parcel to bundle this sandbox, you can find more info about Parcel
  &lt;a href=&quot;https://parceljs.org&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;here&lt;/a&gt;.
&lt;/div&gt;
</code></pre>
<pre><code class="lang-css">body {
  font-family: sans-serif;
}
a {
  color: red;
}
ul {
  li {
    list-style: none;
  }
}
</code></pre>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> Purgecss <span class="hljs-keyword">from</span> <span class="hljs-string">&quot;purgecss&quot;</span>;
<span class="hljs-keyword">const</span> purgecss = <span class="hljs-keyword">new</span> Purgecss({
  <span class="hljs-attr">content</span>: [<span class="hljs-string">&quot;**/*.html&quot;</span>],
  <span class="hljs-attr">css</span>: [<span class="hljs-string">&quot;**/*.css&quot;</span>]
});
<span class="hljs-keyword">const</span> purgecssResult = purgecss.purge();
</code></pre>
<p>&#x6700;&#x7EC8;&#x4EA7;&#x751F;&#x7684;<code>purgecssResult</code>&#x7ED3;&#x679C;&#x5982;&#x4E0B;&#xFF0C;&#x53EF;&#x4EE5;&#x770B;&#x5230;&#x591A;&#x4F59;&#x7684;<code>a</code>&#x548C;<code>ul</code>&#x6807;&#x7B7E;&#x7684;&#x6837;&#x5F0F;&#x90FD;&#x6CA1;&#x4E86;</p>
<h4 id="4-&#x4F5C;&#x7528;&#x57DF;&#x63D2;&#x69FD;"><a name="4-&#x4F5C;&#x7528;&#x57DF;&#x63D2;&#x69FD;" class="anchor-navigation-ex-anchor" href="#4-&#x4F5C;&#x7528;&#x57DF;&#x63D2;&#x69FD;"><i class="fa fa-link" aria-hidden="true"></i></a>4 &#x4F5C;&#x7528;&#x57DF;&#x63D2;&#x69FD;</h4>
<p>&#x5229;&#x7528;&#x597D;&#x4F5C;&#x7528;&#x57DF;&#x63D2;&#x69FD;&#x53EF;&#x4EE5;&#x505A;&#x4E00;&#x4E9B;&#x5F88;&#x6709;&#x610F;&#x601D;&#x7684;&#x4E8B;&#x60C5;&#xFF0C;&#x6BD4;&#x5982;&#x5B9A;&#x4E49;&#x4E00;&#x4E2A;&#x57FA;&#x7840;&#x5E03;&#x5C40;&#x7EC4;&#x4EF6;A&#xFF0C;&#x53EA;&#x8D1F;&#x8D23;&#x5E03;&#x5C40;&#xFF0C;&#x4E0D;&#x7BA1;&#x6570;&#x636E;&#x903B;&#x8F91;&#xFF0C;&#x7136;&#x540E;&#x53E6;&#x5916;&#x5B9A;&#x4E49;&#x4E00;&#x4E2A;&#x7EC4;&#x4EF6;B&#x8D1F;&#x8D23;&#x6570;&#x636E;&#x5904;&#x7406;&#xFF0C;&#x5E03;&#x5C40;&#x7EC4;&#x4EF6;A&#x9700;&#x8981;&#x6570;&#x636E;&#x7684;&#x65F6;&#x5019;&#x5C31;&#x53BB;B&#x91CC;&#x9762;&#x53BB;&#x53D6;&#x3002;&#x5047;&#x8BBE;&#xFF0C;&#x67D0;&#x4E00;&#x5929;&#x6211;&#x4EEC;&#x7684;&#x5E03;&#x5C40;&#x53D8;&#x4E86;&#xFF0C;&#x6211;&#x4EEC;&#x53EA;&#x9700;&#x8981;&#x53BB;&#x4FEE;&#x6539;&#x7EC4;&#x4EF6;A&#x5C31;&#x884C;&#xFF0C;&#x800C;&#x4E0D;&#x7528;&#x53BB;&#x4FEE;&#x6539;&#x7EC4;&#x4EF6;B&#xFF0C;&#x4ECE;&#x800C;&#x5C31;&#x80FD;&#x5145;&#x5206;&#x590D;&#x7528;&#x7EC4;&#x4EF6;B&#x7684;&#x6570;&#x636E;&#x5904;&#x7406;&#x903B;&#x8F91;&#xFF0C;&#x5173;&#x4E8E;&#x8FD9;&#x5757;&#x6211;&#x4E4B;&#x524D;&#x5199;&#x8FC7;&#x4E00;&#x7BC7;&#x5B9E;&#x9645;&#x6848;&#x4F8B;&#x3002;</p>
<p>&#x8FD9;&#x91CC;&#x6D89;&#x53CA;&#x5230;&#x7684;&#x4E00;&#x4E2A;&#x6700;&#x91CD;&#x8981;&#x7684;&#x70B9;&#x5C31;&#x662F;&#x7236;&#x7EC4;&#x4EF6;&#x8981;&#x53BB;&#x83B7;&#x53D6;&#x5B50;&#x7EC4;&#x4EF6;&#x91CC;&#x9762;&#x7684;&#x6570;&#x636E;&#xFF0C;&#x4E4B;&#x524D;&#x662F;&#x5229;&#x7528;<code>slot-scope</code>&#xFF0C;&#x81EA;vue 2.6.0&#x8D77;&#xFF0C;&#x63D0;&#x4F9B;&#x4E86;&#x66F4;&#x597D;&#x7684;&#x652F;&#x6301; <code>slot</code> &#x548C; <code>slot-scope</code> &#x7279;&#x6027;&#x7684; API &#x66FF;&#x4EE3;&#x65B9;&#x6848;&#x3002;</p>
<p>&#x6BD4;&#x5982;&#xFF0C;&#x6211;&#x4EEC;&#x5B9A;&#x4E00;&#x4E2A;&#x540D;&#x4E3A;<code>current-user</code>&#x7684;&#x7EC4;&#x4EF6;&#xFF1A;</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">span</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">slot</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">slot</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span>
</code></pre>
<p>&#x7236;&#x7EC4;&#x4EF6;&#x5F15;&#x7528;<code>current-user</code>&#x7684;&#x7EC4;&#x4EF6;&#xFF0C;&#x4F46;&#x60F3;&#x7528;&#x540D;&#x66FF;&#x4EE3;&#x59D3;&#xFF08;&#x8001;&#x5916;&#x540D;&#x5B57;&#x7B2C;&#x4E00;&#x4E2A;&#x5355;&#x8BCD;&#x662F;&#x540D;&#xFF0C;&#x540E;&#x4E00;&#x4E2A;&#x5355;&#x8BCD;&#x662F;&#x59D3;&#xFF09;&#xFF1A;</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">current-user</span>&gt;</span>

<span class="hljs-tag">&lt;/<span class="hljs-name">current-user</span>&gt;</span>
</code></pre>
<p>&#x8FD9;&#x79CD;&#x65B9;&#x5F0F;&#x4E0D;&#x4F1A;&#x751F;&#x6548;&#xFF0C;&#x56E0;&#x4E3A;<code>user</code>&#x5BF9;&#x8C61;&#x662F;&#x5B50;&#x7EC4;&#x4EF6;&#x7684;&#x6570;&#x636E;&#xFF0C;&#x5728;&#x7236;&#x7EC4;&#x4EF6;&#x91CC;&#x9762;&#x6211;&#x4EEC;&#x83B7;&#x53D6;&#x4E0D;&#x5230;&#xFF0C;&#x8FD9;&#x4E2A;&#x65F6;&#x5019;&#x6211;&#x4EEC;&#x5C31;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;<code>v-slot</code> &#x6765;&#x5B9E;&#x73B0;&#x3002;</p>
<p>&#x9996;&#x5148;&#x5728;&#x5B50;&#x7EC4;&#x4EF6;&#x91CC;&#x9762;&#xFF0C;&#x5C06;<code>user</code>&#x4F5C;&#x4E3A;&#x4E00;&#x4E2A;``&#x5143;&#x7D20;&#x7684;&#x7279;&#x6027;&#x7ED1;&#x5B9A;&#x4E0A;&#x53BB;&#xFF1A;</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">span</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">slot</span> <span class="hljs-attr">v-bind:user</span>=<span class="hljs-string">&quot;user&quot;</span>&gt;</span>

  <span class="hljs-tag">&lt;/<span class="hljs-name">slot</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span>
</code></pre>
<p>&#x4E4B;&#x540E;&#xFF0C;&#x6211;&#x4EEC;&#x5C31;&#x53EF;&#x4EE5;&#x5728;&#x7236;&#x7EC4;&#x4EF6;&#x5F15;&#x7528;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x7ED9;<code>v-slot</code>&#x5E26;&#x4E00;&#x4E2A;&#x503C;&#x6765;&#x5B9A;&#x4E49;&#x6211;&#x4EEC;&#x63D0;&#x4F9B;&#x7684;&#x63D2;&#x69FD; prop &#x7684;&#x540D;&#x5B57;&#xFF1A;</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">current-user</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">template</span> <span class="hljs-attr">v-slot:default</span>=<span class="hljs-string">&quot;slotProps&quot;</span>&gt;</span>

  <span class="hljs-tag">&lt;/<span class="hljs-name">template</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">current-user</span>&gt;</span>
</code></pre>
<p>&#x8FD9;&#x79CD;&#x65B9;&#x5F0F;&#x8FD8;&#x6709;&#x7F29;&#x5199;&#x8BED;&#x6CD5;&#xFF0C;&#x53EF;&#x4EE5;&#x67E5;&#x770B;&#x72EC;&#x5360;&#x9ED8;&#x8BA4;&#x63D2;&#x69FD;&#x7684;&#x7F29;&#x5199;&#x8BED;&#x6CD5;&#xFF0C;&#x6700;&#x7EC8;&#x6211;&#x4EEC;&#x5F15;&#x7528;&#x7684;&#x65B9;&#x5F0F;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">current-user</span> <span class="hljs-attr">v-slot</span>=<span class="hljs-string">&quot;slotProps&quot;</span>&gt;</span>

<span class="hljs-tag">&lt;/<span class="hljs-name">current-user</span>&gt;</span>
</code></pre>
<p>&#x76F8;&#x6BD4;&#x4E4B;&#x524D;<code>slot-scope</code>&#x4EE3;&#x7801;&#x66F4;&#x6E05;&#x6670;&#xFF0C;&#x66F4;&#x597D;&#x7406;&#x89E3;&#x3002;</p>
<h4 id="5-&#x5C5E;&#x6027;&#x4E8B;&#x4EF6;&#x4F20;&#x9012;"><a name="5-&#x5C5E;&#x6027;&#x4E8B;&#x4EF6;&#x4F20;&#x9012;" class="anchor-navigation-ex-anchor" href="#5-&#x5C5E;&#x6027;&#x4E8B;&#x4EF6;&#x4F20;&#x9012;"><i class="fa fa-link" aria-hidden="true"></i></a>5 &#x5C5E;&#x6027;&#x4E8B;&#x4EF6;&#x4F20;&#x9012;</h4>
<p>&#x5199;&#x8FC7;&#x9AD8;&#x9636;&#x7EC4;&#x4EF6;&#x7684;&#x7AE5;&#x978B;&#x53EF;&#x80FD;&#x90FD;&#x4F1A;&#x78B0;&#x5230;&#x8FC7;&#x5C06;&#x52A0;&#x5DE5;&#x8FC7;&#x7684;&#x5C5E;&#x6027;&#x5411;&#x4E0B;&#x4F20;&#x9012;&#x7684;&#x60C5;&#x51B5;&#xFF0C;&#x5982;&#x679C;&#x78B0;&#x5230;&#x5C5E;&#x6027;&#x8F83;&#x591A;&#x65F6;&#xFF0C;&#x9700;&#x8981;&#x4E00;&#x4E2A;&#x4E2A;&#x53BB;&#x4F20;&#x9012;&#xFF0C;&#x975E;&#x5E38;&#x4E0D;&#x53CB;&#x597D;&#x5E76;&#x4E14;&#x8D39;&#x65F6;&#xFF0C;&#x6709;&#x6CA1;&#x6709;&#x4E00;&#x6B21;&#x6027;&#x4F20;&#x9012;&#x7684;&#x5462;&#xFF08;&#x6BD4;&#x5982;react&#x91CC;&#x9762;&#x7684;<code>{...this.props}</code>&#xFF09;&#xFF1F;&#x7B54;&#x6848;&#x5C31;&#x662F;<code>v-bind</code>&#x548C;<code>v-on</code>&#x3002;</p>
<p>&#x4E3E;&#x4E2A;&#x4F8B;&#x5B50;&#xFF0C;&#x5047;&#x5982;&#x6709;&#x4E00;&#x4E2A;&#x57FA;&#x7840;&#x7EC4;&#x4EF6;<code>BaseList</code>&#xFF0C;&#x53EA;&#x6709;&#x57FA;&#x7840;&#x7684;&#x5217;&#x8868;&#x5C55;&#x793A;&#x529F;&#x80FD;&#xFF0C;&#x73B0;&#x5728;&#x6211;&#x4EEC;&#x60F3;&#x5728;&#x8FD9;&#x57FA;&#x7840;&#x4E0A;&#x589E;&#x52A0;&#x6392;&#x5E8F;&#x529F;&#x80FD;&#xFF0C;&#x8FD9;&#x4E2A;&#x65F6;&#x5019;&#x6211;&#x4EEC;&#x5C31;&#x53EF;&#x4EE5;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x9AD8;&#x9636;&#x7EC4;&#x4EF6;<code>SortList</code>&#x3002;</p>
<pre><code class="lang-javascript">&lt;!-- SortList  --&gt;
<span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">template</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">BaseList</span> <span class="hljs-attr">v-bind</span>=<span class="hljs-string">&quot;$props&quot;</span> <span class="hljs-attr">v-on</span>=<span class="hljs-string">&quot;$listeners&quot;</span>&gt;</span> <span class="hljs-comment">&lt;!-- ... --&gt;</span> <span class="hljs-tag">&lt;/<span class="hljs-name">BaseList</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">template</span>&gt;</span></span>

&lt;script&gt;
  <span class="hljs-keyword">import</span> BaseList <span class="hljs-keyword">from</span> <span class="hljs-string">&quot;./BaseList&quot;</span>;
  <span class="hljs-comment">// &#x5305;&#x542B;&#x4E86;&#x57FA;&#x7840;&#x7684;&#x5C5E;&#x6027;&#x5B9A;&#x4E49;</span>
  <span class="hljs-keyword">import</span> BaseListMixin <span class="hljs-keyword">from</span> <span class="hljs-string">&quot;./BaseListMixin&quot;</span>;
  <span class="hljs-comment">// &#x5C01;&#x88C5;&#x4E86;&#x6392;&#x5E8F;&#x7684;&#x903B;&#x8F91;</span>
  <span class="hljs-keyword">import</span> sort <span class="hljs-keyword">from</span> <span class="hljs-string">&quot;./sort.js&quot;</span>;

  <span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> {
    <span class="hljs-attr">props</span>: BaseListMixin.props,
    <span class="hljs-attr">components</span>: {
      BaseList
    }
  };
<span class="xml"><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span></span>
</code></pre>
<p>&#x53EF;&#x4EE5;&#x770B;&#x5230;&#x4F20;&#x9012;&#x5C5E;&#x6027;&#x548C;&#x4E8B;&#x4EF6;&#x7684;&#x65B9;&#x4FBF;&#x6027;&#xFF0C;&#x800C;&#x4E0D;&#x7528;&#x4E00;&#x4E2A;&#x4E2A;&#x53BB;&#x4F20;&#x9012;</p>
<h4 id="6-&#x51FD;&#x6570;&#x5F0F;&#x7EC4;&#x4EF6;"><a name="6-&#x51FD;&#x6570;&#x5F0F;&#x7EC4;&#x4EF6;" class="anchor-navigation-ex-anchor" href="#6-&#x51FD;&#x6570;&#x5F0F;&#x7EC4;&#x4EF6;"><i class="fa fa-link" aria-hidden="true"></i></a>6 &#x51FD;&#x6570;&#x5F0F;&#x7EC4;&#x4EF6;</h4>
<p>&#x51FD;&#x6570;&#x5F0F;&#x7EC4;&#x4EF6;&#xFF0C;&#x5373;&#x65E0;&#x72B6;&#x6001;&#xFF0C;&#x65E0;&#x6CD5;&#x5B9E;&#x4F8B;&#x5316;&#xFF0C;&#x5185;&#x90E8;&#x6CA1;&#x6709;&#x4EFB;&#x4F55;&#x751F;&#x547D;&#x5468;&#x671F;&#x5904;&#x7406;&#x65B9;&#x6CD5;&#xFF0C;&#x975E;&#x5E38;&#x8F7B;&#x91CF;&#xFF0C;&#x56E0;&#x800C;&#x6E32;&#x67D3;&#x6027;&#x80FD;&#x9AD8;&#xFF0C;&#x7279;&#x522B;&#x9002;&#x5408;&#x7528;&#x6765;&#x53EA;&#x4F9D;&#x8D56;&#x5916;&#x90E8;&#x6570;&#x636E;&#x4F20;&#x9012;&#x800C;&#x53D8;&#x5316;&#x7684;&#x7EC4;&#x4EF6;&#x3002;</p>
<p>&#x5199;&#x6CD5;&#x5982;&#x4E0B;&#xFF1A;</p>
<ol>
<li>&#x5728;<code>template</code>&#x6807;&#x7B7E;&#x91CC;&#x9762;&#x6807;&#x660E;<code>functional</code></li>
<li>&#x53EA;&#x63A5;&#x53D7;<code>props</code>&#x503C;</li>
<li>&#x4E0D;&#x9700;&#x8981;<code>script</code>&#x6807;&#x7B7E;</li>
</ol>
<pre><code class="lang-javascript">&lt;!-- App.vue --&gt;
<span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">template</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">id</span>=<span class="hljs-string">&quot;app&quot;</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">List</span>
      <span class="hljs-attr">:items</span>=<span class="hljs-string">&quot;[&apos;Wonderwoman&apos;, &apos;Ironman&apos;]&quot;</span>
      <span class="hljs-attr">:item-click</span>=<span class="hljs-string">&quot;item =&gt; (clicked = item)&quot;</span>
    /&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Clicked hero: <span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">template</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">script</span>&gt;</span><span class="javascript">
<span class="hljs-keyword">import</span> List <span class="hljs-keyword">from</span> <span class="hljs-string">&quot;./List&quot;</span>;

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> {
  <span class="hljs-attr">name</span>: <span class="hljs-string">&quot;App&quot;</span>,
  <span class="hljs-attr">data</span>: <span class="hljs-function"><span class="hljs-params">()</span> =&gt;</span> ({ <span class="hljs-attr">clicked</span>: <span class="hljs-string">&quot;&quot;</span> }),
  <span class="hljs-attr">components</span>: { List }
};
</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
</span></code></pre>
<pre><code class="lang-javascript">&lt;!-- List.vue &#x51FD;&#x6570;&#x5F0F;&#x7EC4;&#x4EF6; --&gt;
<span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">template</span> <span class="hljs-attr">functional</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">p</span> <span class="hljs-attr">v-for</span>=<span class="hljs-string">&quot;item in props.items&quot;</span> @<span class="hljs-attr">click</span>=<span class="hljs-string">&quot;props.itemClick(item);&quot;</span>&gt;</span>

    <span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">template</span>&gt;</span></span>
</code></pre>
<h4 id="7-&#x76D1;&#x542C;&#x7EC4;&#x4EF6;&#x7684;&#x751F;&#x547D;&#x5468;&#x671F;"><a name="7-&#x76D1;&#x542C;&#x7EC4;&#x4EF6;&#x7684;&#x751F;&#x547D;&#x5468;&#x671F;" class="anchor-navigation-ex-anchor" href="#7-&#x76D1;&#x542C;&#x7EC4;&#x4EF6;&#x7684;&#x751F;&#x547D;&#x5468;&#x671F;"><i class="fa fa-link" aria-hidden="true"></i></a>7 &#x76D1;&#x542C;&#x7EC4;&#x4EF6;&#x7684;&#x751F;&#x547D;&#x5468;&#x671F;</h4>
<p>&#x6BD4;&#x5982;&#x6709;&#x7236;&#x7EC4;&#x4EF6;<code>Parent</code>&#x548C;&#x5B50;&#x7EC4;&#x4EF6;<code>Child</code>&#xFF0C;&#x5982;&#x679C;&#x7236;&#x7EC4;&#x4EF6;&#x76D1;&#x542C;&#x5230;&#x5B50;&#x7EC4;&#x4EF6;&#x6302;&#x8F7D;<code>mounted</code>&#x5C31;&#x505A;&#x4E00;&#x4E9B;&#x903B;&#x8F91;&#x5904;&#x7406;&#xFF0C;&#x5E38;&#x89C4;&#x7684;&#x5199;&#x6CD5;&#x53EF;&#x80FD;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// Parent.vue</span>
&lt;Child @mounted=<span class="hljs-string">&quot;doSomething&quot;</span>/&gt;

<span class="hljs-comment">// Child.vue</span>
mounted() {
  <span class="hljs-keyword">this</span>.$emit(<span class="hljs-string">&quot;mounted&quot;</span>);
}
</code></pre>
<footer class="page-footer"><span class="copyright">Copyright &#xA9; zhengyuliang all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x8BE5;&#x6587;&#x4EF6;&#x7F16;&#x5199;&#x65F6;&#x95F4;&#xFF1A;
2019-12-03 17:22:23
</span></footer></body></html>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="../HTML/浏览器里的本地数据库：IndexedDB.html" class="navigation navigation-prev " aria-label="Previous page: 浏览器里的本地数据库：IndexedDB">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="Vue this.$router.push、replace、go的区别.html" class="navigation navigation-next " aria-label="Next page: Vue This.$Router.Push、Replace、Go的区别">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"7个有用的Vue开发技巧","level":"3.1","depth":1,"next":{"title":"Vue This.$Router.Push、Replace、Go的区别","level":"3.2","depth":1,"path":"Vue/Vue this.$router.push、replace、go的区别.md","ref":"Vue/Vue this.$router.push、replace、go的区别.md","articles":[]},"previous":{"title":"浏览器里的本地数据库：IndexedDB","level":"2.1","depth":1,"path":"HTML/浏览器里的本地数据库：IndexedDB.md","ref":"HTML/浏览器里的本地数据库：IndexedDB.md","articles":[]},"dir":"ltr"},"config":{"plugins":["sectionx","splitter","tbfed-pagefooter","toggle-chapters","theme-comscore","-lunr","-search","search-plus","donate","anchor-navigation-ex","expandable-chapters","chapter-fold","expandable-chapters-small","livereload"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"Copyright &copy zhengyuliang","modify_label":"该文件编写时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"chapter-fold":{},"pluginsConfig":{"anchor-navigation-ex":{"showLevel":false,"showGoTop":true,"isRewritePageTitle":true,"isShowTocTitleIcon":true,"tocLevel1Icon":"fa fa-hand-o-right","tocLevel2Icon":"fa fa-hand-o-right","tocLevel3Icon":"fa fa-hand-o-right"}},"livereload":{},"splitter":{},"donate":{"title":"","button":"赏","wechat":"https://gitee.com/htzyl/img_bed/raw/master/pay/weixin-min.jpg","alipay":"https://gitee.com/htzyl/img_bed/raw/master/pay/alipay-min.jpg","wechatText":"微信打赏","alipayText":"支付宝打赏"},"fontsettings":{"theme":"white","family":"sans","size":2},"sectionx":{"tag":"b"},"highlight":{},"anchor-navigation-ex":{"showLevel":true,"associatedWithSummary":true,"mode":"float","showGoTop":true,"printLog":false,"multipleH1":true,"float":{"floatIcon":"fa fa-navicon","showLevelIcon":false,"level1Icon":"","level2Icon":"","level3Icon":""},"pageTop":{"showLevelIcon":false,"level1Icon":"","level2Icon":"","level3Icon":""}},"theme-comscore":{},"expandable-chapters-small":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"toggle-chapters":{},"expandable-chapters":{},"search-plus":{}},"theme":"default","author":"zhengyuliang","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"记录技术文档内容","language":"zh-hans","gitbook":">=3.0.0","description":"记录Gitbook的配置和一些插件的使用","theme-default":{"showLevel":true}},"file":{"path":"Vue/7个有用的Vue开发技巧.md","mtime":"2019-12-03T09:22:23.320Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2022-01-06T09:44:01.178Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sectionx/sectionx.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-toggle-chapters/toggle.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-plus/jquery.mark.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-plus/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-donate/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    </body>
</html>

